//
//  FFRecvPayPayUserCell.m
//  LLWallet
//
//  Created by tt on 2020/12/23.
//

#import "FFRecvPayPayUserCell.h"


@implementation FFRecvPayPayUserModel

- (Class)cell {
    return FFRecvPayPayUserCell.class;
}

@end

@interface FFRecvPayPayUserCell ()

@property(nonatomic,strong) UIImageView *avatarImgView;
@property(nonatomic,strong) UILabel *nameLbl;

@end

@implementation FFRecvPayPayUserCell

+ (CGSize)sizeForModel:(WKFormItemModel *)model {
    return CGSizeMake(WKScreenWidth, 100.0f);
}

- (void)setupUI {
    [super setupUI];
    [self setBackgroundColor:[WKApp shared].config.backgroundColor];
    [self addSubview:self.avatarImgView];
    [self addSubview:self.nameLbl];
    
}

- (void)refresh:(FFRecvPayPayUserModel *)model {
    [super refresh:model];
    
    [self.avatarImgView lim_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[WKApp shared].config.defaultAvatar];
    self.nameLbl.text = model.name;
}

- (UIImageView *)avatarImgView {
    if(!_avatarImgView) {
        _avatarImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 45.0f, 45.0f)];
        _avatarImgView.layer.masksToBounds = YES;
        _avatarImgView.layer.cornerRadius = _avatarImgView.lim_height/2.0f;
    }
    return _avatarImgView;
}

- (UILabel *)nameLbl {
    if(!_nameLbl) {
        _nameLbl = [[UILabel alloc] init];
        _nameLbl.font = [[WKApp shared].config appFontOfSizeMedium:16.0f];
    }
    return _nameLbl;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.avatarImgView.lim_left = self.lim_width/2.0f - self.avatarImgView.lim_width/2.0f;
    
    [self.nameLbl sizeToFit];
    if(self.nameLbl.lim_width> self.lim_width-30.0f) {
        self.nameLbl.lim_width = self.lim_width - 30.0f;
    }
    self.nameLbl.lim_top = self.avatarImgView.lim_bottom + 10.0f;
    self.nameLbl.lim_left = self.lim_width/2.0f - self.nameLbl.lim_width/2.0f;
    
}

@end
